(function() {
    var backtop=document.getElementById('backTop');
    // console.log(backtop)
    var timer;

    backtop.onclick=function(){
        clearInterval(timer);
        timer=setInterval(function(){
            document.documentElement.scrollTop-=100;
            if(document.documentElement.scrollTop<=0){
                clearInterval(timer);
            };
        },20);
    };
    // 监听
    window.onscroll=function(){
        var scroll=document.documentElement.scrollTop || window.scrollY
        console.log(scroll);
        if(scroll==0){
            backtop.style.display='none';
        }else{
            backtop.style.display='block';
        }
    }
})();